/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xos_base.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#include "../import/head.h"
#include "state.h"

namespace xos_base
{
    namespace state
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // 

        enum enumState
        {
            STATE_STARTING,
            STATE_RUNNING,
            STATE_QUITTING,
            STATE_STOPPED
        };

        static int sys_state_n = STATE_STARTING;

        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // 

        bool running()
        {
            return STATE_RUNNING == sys_state_n;
        }

        bool starting()
        {
            return STATE_STARTING == sys_state_n;
        }

        bool quitting()
        {
            return STATE_QUITTING == sys_state_n;
        }

        bool stopped()
        {
            return STATE_STOPPED == sys_state_n;
        }

        int set_running()
        {
            int ret = 0;
            sys_state_n = STATE_RUNNING;
            return ret;
        }

        int set_starting()
        {
            int ret = 0;
            sys_state_n = STATE_STARTING;
            return ret;
        }

        int set_quitting()
        {
            int ret = 0;
            sys_state_n = STATE_QUITTING;
            return ret;
        }

        int set_stopped()
        {
            int ret = 0;
            sys_state_n = STATE_STOPPED;
            return ret;
        }

    } // state
} // xos_base
